from sqlalchemy.ext.asyncio import AsyncSession as Session
from app.models.xm.xm_buy_order import XMBuyOrder
from app.schemas.xm.xm_buy_order import XMBuyOrderCreate


async def create_xm_buy_order(
    session: Session,
    xm_buy_order: XMBuyOrderCreate,
):
    """创建XM购买订单"""
    db_xm_buy_order = XMBuyOrder(**xm_buy_order.model_dump())
    session.add(db_xm_buy_order)
    await session.commit()
    await session.refresh(db_xm_buy_order)
    return db_xm_buy_order